const db = wx.cloud.database();
let recordsCollection = db.collection('records');
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    recordsCollection.orderBy('time', 'DESC').get().then(res => {
      console.log(res.data[0])
      this.setData({
        list: res.data
      })
    })
  },
  notify() {
    wx.requestSubscribeMessage({
      tmplIds: ['D6wOUVoU1VXScIxra0DxKiVXHe99VDOsLYLlrZtLPQ4'],
      success: res => {
        if (res['D6wOUVoU1VXScIxra0DxKiVXHe99VDOsLYLlrZtLPQ4']) {
          notifyCollection.add({
            data: {
              tmpId: "D6wOUVoU1VXScIxra0DxKiVXHe99VDOsLYLlrZtLPQ4"
            }
          }).then(() => {
            this.goToIndex();
          });
        }
      },
      fail: console.error
    })
  }
})